package com.credit.mola.app.utils.dialog

import android.content.Context
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.WindowManager
import com.credit.mola.app.R
import com.credit.mola.app.databinding.DialogSubmitSuccessBinding
import com.credit.mola.app.pro.ProDialog

/**
 * Sikadwa
 * @Author wwdeng
 * @CreateTime: 2024/7/31 13:45
 * @Annotation：手机号校验，发送验证码成功dialog
 */
class SubmitSuccessDialog: ProDialog {
    private lateinit var binding: DialogSubmitSuccessBinding
    private var mCallback: IDialogCallback? = null

    override fun initWindow() {
        val params = window?.attributes
        params?.width = WindowManager.LayoutParams.WRAP_CONTENT
        params?.height = WindowManager.LayoutParams.WRAP_CONTENT
        window?.attributes = params
        window?.setWindowAnimations(R.style.dialog_scale_anim) //修改动画样式
        window?.setGravity(Gravity.CENTER)
    }

    constructor(context: Context) : super(context) {}
    constructor(context: Context, callback: IDialogCallback?) : super(context) {
        mCallback = callback
    }

    /**
     * 设置点击回调
     */
    fun setOnClick(callback: IDialogCallback){
        this.mCallback = callback
    }

    override fun getRootView(): View {
        binding = DialogSubmitSuccessBinding.inflate(LayoutInflater.from(context))
        return binding.root
    }

    override fun initView() {
    }

    override fun initListener() {
    }

    override fun initData() {
    }

    /**
     * 设置提示文案
     */
    fun showSubmitSuccess(tips: String){
        binding.textSubmitSuccess.text = tips
    }

    override fun onViewClick(v: View?) {
        dismiss()
    }

    interface IDialogCallback {
        //按钮点击
        fun onClick(view: View?)
    }
}